package everyday3;

import java.util.Arrays;

/**
 * @Author: Siantar
 * @Date: 2024-07-08-8:52
 * @Description: 1.0
 */
public class T0724 {
    public int pivotIndex(int[] nums) {
        int sum = Arrays.stream(nums).sum(), leftSum = 0;
        for (int i = 0; i < nums.length; i++) {
            if (leftSum * 2 + nums[i] == sum) return i;
            else leftSum += nums[i];
        }
        return -1;
    }

}
